<?php

	if ($_POST[doupdate]) {

    	$storona = Normalize($_POST[storona]);
        if ($storona != 1 and $storona != 2)
        	$storona = 1;

        	$pass = Normalize($_POST[pass]);

	            $langu = Normalize($_POST[langu]);
	            if ($langu == 'en')
	                $langu = "English";
	            elseif ($langu == 'ru')
	                $langu = "Russian";
	            else
	                $langu = "English";

	        mysql_query("
            update
            	pilots
            set
                LOCAL='$langu'
            where
            	id='$user_status_thrown_pilot'
            ");

            if ($pass) 	{
	            mysql_query("
	            update
	                pilots
	            set
	                password='$pass'
	            where
	                id='$user_status_thrown_pilot'
	            ");

	            $TPmain = new TemplateHandler();

                FillTemplateCommonData();

	            $TPmain->AssignTag("<!--CONTENT-->","<div align=center>".$SLANG[$lang][changepass][yes]."</div>");
        	}
            else {
	            $pilot = GetPilotById ($user_status_thrown_pilot);

	            //echo var_dump($pilot);
	            $VARS[pilot] = GetPilotById ($user_status_thrown_pilot);

	            $TPmain = new TemplateHandler();

	            FillTemplateCommonData();

	            $TPmain2 = new TemplateHandler("templates/profile.htm");

	            $TPmain->AssignTag("<!--CONTENT-->",$TPmain2->Parse());
            }


    }
    elseif ($_POST[dotime]) {

    	$ip = $_POST[ip];

        ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$ip,$args);

		$ip = $args[0];

    	if (ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$ip)) {

	        if (mktime($_POST[hour],0,0,$_POST[month],$_POST[day],$_POST[year]) < time()) {
	                        $_POST[hour] = date("H",time()+3600);
	                        $_POST[year] = date("Y",time()+3600);
	                        $_POST[month] = date("m",time()+3600);
	                        $_POST[day] = date("d",time()+3600);
	        }

	        mysql_query("update pilots set ip='$ip', logon_time='".date("Y-m-d H-i-s",time())."', end_time='".date("Y-m-d H-i-s",mktime($_POST[hour],0,0,$_POST[month],$_POST[day],$_POST[year]))."' where id='$user_status_thrown_pilot'");
	//echo "update pilots set ip='".$_SERVER['REMOTE_ADDR']."', logon_time='".date("Y-m-d H-i-s",time())."', end_time='".date("Y-m-d H-i-s",mktime($_POST[hour],0,0,$_POST[month],$_POST[day],$_POST[year]))."' where id='$user_status_thrown_pilot'";

	        $pilot = GetPilotById ($user_status_thrown_pilot);

	        //echo var_dump($pilot);
	        $VARS[pilot] = GetPilotById ($user_status_thrown_pilot);
		}

        $TPmain = new TemplateHandler();

        FillTemplateCommonData();

		$TPmain2 = new TemplateHandler("templates/profile.htm");

        $TPmain->AssignTag("<!--CONTENT-->",$TPmain2->Parse());

    }
	else {

        $pilot = GetPilotById ($user_status_thrown_pilot);

		//echo var_dump($pilot);
        $VARS[pilot] = GetPilotById ($user_status_thrown_pilot);

        $TPmain = new TemplateHandler();

        FillTemplateCommonData();

		$TPmain2 = new TemplateHandler("templates/profile.htm");

        $TPmain->AssignTag("<!--CONTENT-->",$TPmain2->Parse());
    }

?>